package com.xxx.sevlet;

import com.xxx.pojo.User;
import com.xxx.sevice.addUserlistimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/user")
public class UserServlet extends HttpServlet {
    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");
        final addUserlistimpl addUserlist = new addUserlistimpl();
        final String name = req.getParameter("name");
        final String age = req.getParameter("age");
        addUserlist.addUser(new User(name, Integer.parseInt(age)));
        req.getRequestDispatcher("/success.jsp").forward(req, resp);

    }


}
